package SmartHome.handlers;

import SmartHome.devices.AirConditioner;
import SmartHome.strategys.FastResponseStrategy;

public class AirConditionerHandler extends Handler {
    private Handler nextHandler;
    private final AirConditioner airConditioner = new AirConditioner();

    @Override
    public void setNextHandler(Handler nextHandler) {
        this.nextHandler = nextHandler;
    }

    @Override
    public void handleRequest(String request) {
        if (request.contains("空调")) {
            System.out.println("ACHandler: 处理空调指令-->" + request);
            airConditioner.setStrategy(new FastResponseStrategy());
            //默认为快速响应策略
            airConditioner.start();
        } else {
            if (nextHandler != null) {
                nextHandler.handleRequest(request);
            } else {
                System.out.println("ACHandler: 无法处理该请求-->" + request);
            }
        }
    }
}
